<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Model_t_siswa extends CI_Model 
{
    function __construct()
    {
        parent::__construct();
 
		$this->load->database();

		// Paginaiton defaults
		$this->pagination_enabled = FALSE;
		$this->pagination_per_page = 10;
		$this->pagination_num_links = 5;
		$this->pager = '';

        /**
		 *    bool $this->raw_data		
		 *    Used to decide what data should the SQL queries retrieve if tables are joined
		 *     - TRUE:  just the field names of the t_siswa table
		 *     - FALSE: related fields are replaced with the forign tables values
		 *    Triggered to TRUE in the controller/edit method		 
		 */
        $this->raw_data = FALSE;  
    }

	function get ( $id, $get_one = false )
	{
        
	    $select_statement = ( $this->raw_data ) ? 'NIS,NO_CALSIS,NM_SISWA,NM_PANGGILAN,KD_JENIS_KELAMIN,KOTA_LAHIR,TANGGAL_LAHIR,ALAMAT,RT,RW,KD_POS,KD_GOL_DARAH,KD_AGAMA,NO_TELP,NO_HP,STATUS_SISWA,KEWARGANEGARAAN,ANAK_KE,JUMLAH_KANDUNG,JUMLAH_TIRI,JUMLAH_ANGKAT,STATUS_YATIM_PIATU,BAHASA,TINGGAL_DI,JARAK_SEK,KELAINAN_JASMANI,BERAT_BADAN,TINGGI_BADAN,ASAL_SMP,NO_STL_SMP,TANGGAL_STL_SMP,LAMA_BELAJAR_SMP,ASAL_SMA,KD_TINGKAT_KELAS,KD_PROGRAM_PENGAJARAN,DITERIMA_TANGGAL,PINDAH_ALASAN,HUBUNGI,TANGGUNG_BIAYA,TEMP_AKSES_NET,FREK_AKSES_NET,FREK_REKRE_KEL,NILAI,NO_INDUK,DIR_FOTO,STATUS_ENTRI,KD_JENIS_KETUNAAN,KD_STATUS_DALAM_KELUARGA,TANGGAL_SKHUN_SMP,NO_SKHUN_SMP,NISN,NIK,JENIS_TINGGAL,KELURAHAN_DESA,KECAMATAN,KABUPATEN_KOTA,PROPINSI,KD_AREA,KD_JARAK_SEK,ALAT_TRANSPORTASI,EMAIL_PRIBADI,USERNAME,TANGGAL_AKSES' : 'NIS,NO_CALSIS,NM_SISWA,NM_PANGGILAN,KD_JENIS_KELAMIN,KOTA_LAHIR,TANGGAL_LAHIR,ALAMAT,RT,RW,KD_POS,KD_GOL_DARAH,KD_AGAMA,NO_TELP,NO_HP,STATUS_SISWA,KEWARGANEGARAAN,ANAK_KE,JUMLAH_KANDUNG,JUMLAH_TIRI,JUMLAH_ANGKAT,STATUS_YATIM_PIATU,BAHASA,TINGGAL_DI,JARAK_SEK,KELAINAN_JASMANI,BERAT_BADAN,TINGGI_BADAN,ASAL_SMP,NO_STL_SMP,TANGGAL_STL_SMP,LAMA_BELAJAR_SMP,ASAL_SMA,KD_TINGKAT_KELAS,KD_PROGRAM_PENGAJARAN,DITERIMA_TANGGAL,PINDAH_ALASAN,HUBUNGI,TANGGUNG_BIAYA,TEMP_AKSES_NET,FREK_AKSES_NET,FREK_REKRE_KEL,NILAI,NO_INDUK,DIR_FOTO,STATUS_ENTRI,KD_JENIS_KETUNAAN,KD_STATUS_DALAM_KELUARGA,TANGGAL_SKHUN_SMP,NO_SKHUN_SMP,NISN,NIK,JENIS_TINGGAL,KELURAHAN_DESA,KECAMATAN,KABUPATEN_KOTA,PROPINSI,KD_AREA,KD_JARAK_SEK,ALAT_TRANSPORTASI,EMAIL_PRIBADI,USERNAME,TANGGAL_AKSES';
		$this->db->select( $select_statement );
		$this->db->from('t_siswa');
        

		// Pick one record
		// Field order sample may be empty because no record is requested, eg. create/GET event
		if( $get_one )
        {
            $this->db->limit(1,0);
        }
		else // Select the desired record
        {
            $this->db->where( 'NIS', $id );
        }

		$query = $this->db->get();

		if ( $query->num_rows() > 0 )
		{
			$row = $query->row_array();
			return array( 
	'NIS' => $row['NIS'],
	'NO_CALSIS' => $row['NO_CALSIS'],
	'NM_SISWA' => $row['NM_SISWA'],
	'NM_PANGGILAN' => $row['NM_PANGGILAN'],
	'KD_JENIS_KELAMIN' => $row['KD_JENIS_KELAMIN'],
	'KOTA_LAHIR' => $row['KOTA_LAHIR'],
	'TANGGAL_LAHIR' => $row['TANGGAL_LAHIR'],
	'ALAMAT' => $row['ALAMAT'],
	'RT' => $row['RT'],
	'RW' => $row['RW'],
	'KD_POS' => $row['KD_POS'],
	'KD_GOL_DARAH' => $row['KD_GOL_DARAH'],
	'KD_AGAMA' => $row['KD_AGAMA'],
	'NO_TELP' => $row['NO_TELP'],
	'NO_HP' => $row['NO_HP'],
	'STATUS_SISWA' => $row['STATUS_SISWA'],
	'KEWARGANEGARAAN' => $row['KEWARGANEGARAAN'],
	'ANAK_KE' => $row['ANAK_KE'],
	'JUMLAH_KANDUNG' => $row['JUMLAH_KANDUNG'],
	'JUMLAH_TIRI' => $row['JUMLAH_TIRI'],
	'JUMLAH_ANGKAT' => $row['JUMLAH_ANGKAT'],
	'STATUS_YATIM_PIATU' => $row['STATUS_YATIM_PIATU'],
	'BAHASA' => $row['BAHASA'],
	'TINGGAL_DI' => $row['TINGGAL_DI'],
	'JARAK_SEK' => $row['JARAK_SEK'],
	'KELAINAN_JASMANI' => $row['KELAINAN_JASMANI'],
	'BERAT_BADAN' => $row['BERAT_BADAN'],
	'TINGGI_BADAN' => $row['TINGGI_BADAN'],
	'ASAL_SMP' => $row['ASAL_SMP'],
	'NO_STL_SMP' => $row['NO_STL_SMP'],
	'TANGGAL_STL_SMP' => $row['TANGGAL_STL_SMP'],
	'LAMA_BELAJAR_SMP' => $row['LAMA_BELAJAR_SMP'],
	'ASAL_SMA' => $row['ASAL_SMA'],
	'KD_TINGKAT_KELAS' => $row['KD_TINGKAT_KELAS'],
	'KD_PROGRAM_PENGAJARAN' => $row['KD_PROGRAM_PENGAJARAN'],
	'DITERIMA_TANGGAL' => $row['DITERIMA_TANGGAL'],
	'PINDAH_ALASAN' => $row['PINDAH_ALASAN'],
	'HUBUNGI' => $row['HUBUNGI'],
	'TANGGUNG_BIAYA' => $row['TANGGUNG_BIAYA'],
	'TEMP_AKSES_NET' => $row['TEMP_AKSES_NET'],
	'FREK_AKSES_NET' => $row['FREK_AKSES_NET'],
	'FREK_REKRE_KEL' => $row['FREK_REKRE_KEL'],
	'NILAI' => $row['NILAI'],
	'NO_INDUK' => $row['NO_INDUK'],
	'DIR_FOTO' => $row['DIR_FOTO'],
	'STATUS_ENTRI' => $row['STATUS_ENTRI'],
	'KD_JENIS_KETUNAAN' => $row['KD_JENIS_KETUNAAN'],
	'KD_STATUS_DALAM_KELUARGA' => $row['KD_STATUS_DALAM_KELUARGA'],
	'TANGGAL_SKHUN_SMP' => $row['TANGGAL_SKHUN_SMP'],
	'NO_SKHUN_SMP' => $row['NO_SKHUN_SMP'],
	'NISN' => $row['NISN'],
	'NIK' => $row['NIK'],
	'JENIS_TINGGAL' => $row['JENIS_TINGGAL'],
	'KELURAHAN_DESA' => $row['KELURAHAN_DESA'],
	'KECAMATAN' => $row['KECAMATAN'],
	'KABUPATEN_KOTA' => $row['KABUPATEN_KOTA'],
	'PROPINSI' => $row['PROPINSI'],
	'KD_AREA' => $row['KD_AREA'],
	'KD_JARAK_SEK' => $row['KD_JARAK_SEK'],
	'ALAT_TRANSPORTASI' => $row['ALAT_TRANSPORTASI'],
	'EMAIL_PRIBADI' => $row['EMAIL_PRIBADI'],
	'USERNAME' => $row['USERNAME'],
	'TANGGAL_AKSES' => $row['TANGGAL_AKSES'],
 );
		}
        else
        {
            return array();
        }
	}



	function insert ( $data )
	{
		$this->db->insert( 't_siswa', $data );
		return $this->db->insert_id();
	}
	


	function update ( $id, $data )
	{
		$this->db->where( 'NIS', $id );
		$this->db->update( 't_siswa', $data );
	}


	
	function delete ( $id )
	{
        if( is_array( $id ) )
        {
            $this->db->where_in( 'NIS', $id );            
        }
        else
        {
            $this->db->where( 'NIS', $id );
        }
        $this->db->delete( 't_siswa' );
        
	}



	function lister ( $page = FALSE )
	{
        
	    $this->db->start_cache();
		$this->db->select( 'NIS,NO_CALSIS,NM_SISWA,NM_PANGGILAN,KD_JENIS_KELAMIN,KOTA_LAHIR,TANGGAL_LAHIR,ALAMAT,RT,RW,KD_POS,KD_GOL_DARAH,KD_AGAMA,NO_TELP,NO_HP,STATUS_SISWA,KEWARGANEGARAAN,ANAK_KE,JUMLAH_KANDUNG,JUMLAH_TIRI,JUMLAH_ANGKAT,STATUS_YATIM_PIATU,BAHASA,TINGGAL_DI,JARAK_SEK,KELAINAN_JASMANI,BERAT_BADAN,TINGGI_BADAN,ASAL_SMP,NO_STL_SMP,TANGGAL_STL_SMP,LAMA_BELAJAR_SMP,ASAL_SMA,KD_TINGKAT_KELAS,KD_PROGRAM_PENGAJARAN,DITERIMA_TANGGAL,PINDAH_ALASAN,HUBUNGI,TANGGUNG_BIAYA,TEMP_AKSES_NET,FREK_AKSES_NET,FREK_REKRE_KEL,NILAI,NO_INDUK,DIR_FOTO,STATUS_ENTRI,KD_JENIS_KETUNAAN,KD_STATUS_DALAM_KELUARGA,TANGGAL_SKHUN_SMP,NO_SKHUN_SMP,NISN,NIK,JENIS_TINGGAL,KELURAHAN_DESA,KECAMATAN,KABUPATEN_KOTA,PROPINSI,KD_AREA,KD_JARAK_SEK,ALAT_TRANSPORTASI,EMAIL_PRIBADI,USERNAME,TANGGAL_AKSES');
		$this->db->from( 't_siswa' );
		//$this->db->order_by( '', 'ASC' );
        

        /**
         *   PAGINATION
         */
        if( $this->pagination_enabled == TRUE )
        {
            $config = array();
            $config['total_rows']  = $this->db->count_all_results('t_siswa');
            $config['base_url']    = 't_siswa/index/';
            $config['uri_segment'] = 3;
            $config['cur_tag_open'] = '<span class="current">';
            $config['cur_tag_close'] = '</span>';
            $config['per_page']    = $this->pagination_per_page;
            $config['num_links']   = $this->pagination_num_links;

            $this->load->library('pagination');
            $this->pagination->initialize($config);
            $this->pager = $this->pagination->create_links();
    
            $this->db->limit( $config['per_page'], $page );
        }

        // Get the results
		$query = $this->db->get();
		
		$temp_result = array();

		foreach ( $query->result_array() as $row )
		{
			$temp_result[] = array( 
	'NIS' => $row['NIS'],
	'NO_CALSIS' => $row['NO_CALSIS'],
	'NM_SISWA' => $row['NM_SISWA'],
	'NM_PANGGILAN' => $row['NM_PANGGILAN'],
	'KD_JENIS_KELAMIN' => $row['KD_JENIS_KELAMIN'],
	'KOTA_LAHIR' => $row['KOTA_LAHIR'],
	'TANGGAL_LAHIR' => $row['TANGGAL_LAHIR'],
	'ALAMAT' => $row['ALAMAT'],
	'RT' => $row['RT'],
	'RW' => $row['RW'],
	'KD_POS' => $row['KD_POS'],
	'KD_GOL_DARAH' => $row['KD_GOL_DARAH'],
	'KD_AGAMA' => $row['KD_AGAMA'],
	'NO_TELP' => $row['NO_TELP'],
	'NO_HP' => $row['NO_HP'],
	'STATUS_SISWA' => $row['STATUS_SISWA'],
	'KEWARGANEGARAAN' => $row['KEWARGANEGARAAN'],
	'ANAK_KE' => $row['ANAK_KE'],
	'JUMLAH_KANDUNG' => $row['JUMLAH_KANDUNG'],
	'JUMLAH_TIRI' => $row['JUMLAH_TIRI'],
	'JUMLAH_ANGKAT' => $row['JUMLAH_ANGKAT'],
	'STATUS_YATIM_PIATU' => $row['STATUS_YATIM_PIATU'],
	'BAHASA' => $row['BAHASA'],
	'TINGGAL_DI' => $row['TINGGAL_DI'],
	'JARAK_SEK' => $row['JARAK_SEK'],
	'KELAINAN_JASMANI' => $row['KELAINAN_JASMANI'],
	'BERAT_BADAN' => $row['BERAT_BADAN'],
	'TINGGI_BADAN' => $row['TINGGI_BADAN'],
	'ASAL_SMP' => $row['ASAL_SMP'],
	'NO_STL_SMP' => $row['NO_STL_SMP'],
	'TANGGAL_STL_SMP' => $row['TANGGAL_STL_SMP'],
	'LAMA_BELAJAR_SMP' => $row['LAMA_BELAJAR_SMP'],
	'ASAL_SMA' => $row['ASAL_SMA'],
	'KD_TINGKAT_KELAS' => $row['KD_TINGKAT_KELAS'],
	'KD_PROGRAM_PENGAJARAN' => $row['KD_PROGRAM_PENGAJARAN'],
	'DITERIMA_TANGGAL' => $row['DITERIMA_TANGGAL'],
	'PINDAH_ALASAN' => $row['PINDAH_ALASAN'],
	'HUBUNGI' => $row['HUBUNGI'],
	'TANGGUNG_BIAYA' => $row['TANGGUNG_BIAYA'],
	'TEMP_AKSES_NET' => $row['TEMP_AKSES_NET'],
	'FREK_AKSES_NET' => $row['FREK_AKSES_NET'],
	'FREK_REKRE_KEL' => $row['FREK_REKRE_KEL'],
	'NILAI' => $row['NILAI'],
	'NO_INDUK' => $row['NO_INDUK'],
	'DIR_FOTO' => $row['DIR_FOTO'],
	'STATUS_ENTRI' => $row['STATUS_ENTRI'],
	'KD_JENIS_KETUNAAN' => $row['KD_JENIS_KETUNAAN'],
	'KD_STATUS_DALAM_KELUARGA' => $row['KD_STATUS_DALAM_KELUARGA'],
	'TANGGAL_SKHUN_SMP' => $row['TANGGAL_SKHUN_SMP'],
	'NO_SKHUN_SMP' => $row['NO_SKHUN_SMP'],
	'NISN' => $row['NISN'],
	'NIK' => $row['NIK'],
	'JENIS_TINGGAL' => $row['JENIS_TINGGAL'],
	'KELURAHAN_DESA' => $row['KELURAHAN_DESA'],
	'KECAMATAN' => $row['KECAMATAN'],
	'KABUPATEN_KOTA' => $row['KABUPATEN_KOTA'],
	'PROPINSI' => $row['PROPINSI'],
	'KD_AREA' => $row['KD_AREA'],
	'KD_JARAK_SEK' => $row['KD_JARAK_SEK'],
	'ALAT_TRANSPORTASI' => $row['ALAT_TRANSPORTASI'],
	'EMAIL_PRIBADI' => $row['EMAIL_PRIBADI'],
	'USERNAME' => $row['USERNAME'],
	'TANGGAL_AKSES' => $row['TANGGAL_AKSES'],
 );
		}
        $this->db->flush_cache(); 
		return $temp_result;
	}



	function search ( $keyword, $page = FALSE )
	{
	    $meta = $this->metadata();
	    $this->db->start_cache();
		$this->db->select( 'NIS,NO_CALSIS,NM_SISWA,NM_PANGGILAN,KD_JENIS_KELAMIN,KOTA_LAHIR,TANGGAL_LAHIR,ALAMAT,RT,RW,KD_POS,KD_GOL_DARAH,KD_AGAMA,NO_TELP,NO_HP,STATUS_SISWA,KEWARGANEGARAAN,ANAK_KE,JUMLAH_KANDUNG,JUMLAH_TIRI,JUMLAH_ANGKAT,STATUS_YATIM_PIATU,BAHASA,TINGGAL_DI,JARAK_SEK,KELAINAN_JASMANI,BERAT_BADAN,TINGGI_BADAN,ASAL_SMP,NO_STL_SMP,TANGGAL_STL_SMP,LAMA_BELAJAR_SMP,ASAL_SMA,KD_TINGKAT_KELAS,KD_PROGRAM_PENGAJARAN,DITERIMA_TANGGAL,PINDAH_ALASAN,HUBUNGI,TANGGUNG_BIAYA,TEMP_AKSES_NET,FREK_AKSES_NET,FREK_REKRE_KEL,NILAI,NO_INDUK,DIR_FOTO,STATUS_ENTRI,KD_JENIS_KETUNAAN,KD_STATUS_DALAM_KELUARGA,TANGGAL_SKHUN_SMP,NO_SKHUN_SMP,NISN,NIK,JENIS_TINGGAL,KELURAHAN_DESA,KECAMATAN,KABUPATEN_KOTA,PROPINSI,KD_AREA,KD_JARAK_SEK,ALAT_TRANSPORTASI,EMAIL_PRIBADI,USERNAME,TANGGAL_AKSES');
		$this->db->from( 't_siswa' );
        

		// Delete this line after setting up the search conditions 
        die('Please see models/model_t_siswa.php for setting up the search method.');
		
        /**
         *  Rename field_name_to_search to the field you wish to search 
         *  or create advanced search conditions here
		 */
        $this->db->where( 'field_name_to_search LIKE "%'.$keyword.'%"' );

        /**
         *   PAGINATION
         */
        if( $this->pagination_enabled == TRUE )
        {
            $config = array();
            $config['total_rows']  = $this->db->count_all_results('t_siswa');
            $config['base_url']    = '/t_siswa/search/'.$keyword.'/';
            $config['uri_segment'] = 4;
            $config['per_page']    = $this->pagination_per_page;
            $config['num_links']   = $this->pagination_num_links;
    
            $this->load->library('pagination');
            $this->pagination->initialize($config);
            $this->pager = $this->pagination->create_links();
    
            $this->db->limit( $config['per_page'], $page );
        }

		$query = $this->db->get();

		$temp_result = array();

		foreach ( $query->result_array() as $row )
		{
			$temp_result[] = array( 
	'NIS' => $row['NIS'],
	'NO_CALSIS' => $row['NO_CALSIS'],
	'NM_SISWA' => $row['NM_SISWA'],
	'NM_PANGGILAN' => $row['NM_PANGGILAN'],
	'KD_JENIS_KELAMIN' => $row['KD_JENIS_KELAMIN'],
	'KOTA_LAHIR' => $row['KOTA_LAHIR'],
	'TANGGAL_LAHIR' => $row['TANGGAL_LAHIR'],
	'ALAMAT' => $row['ALAMAT'],
	'RT' => $row['RT'],
	'RW' => $row['RW'],
	'KD_POS' => $row['KD_POS'],
	'KD_GOL_DARAH' => $row['KD_GOL_DARAH'],
	'KD_AGAMA' => $row['KD_AGAMA'],
	'NO_TELP' => $row['NO_TELP'],
	'NO_HP' => $row['NO_HP'],
	'STATUS_SISWA' => $row['STATUS_SISWA'],
	'KEWARGANEGARAAN' => $row['KEWARGANEGARAAN'],
	'ANAK_KE' => $row['ANAK_KE'],
	'JUMLAH_KANDUNG' => $row['JUMLAH_KANDUNG'],
	'JUMLAH_TIRI' => $row['JUMLAH_TIRI'],
	'JUMLAH_ANGKAT' => $row['JUMLAH_ANGKAT'],
	'STATUS_YATIM_PIATU' => $row['STATUS_YATIM_PIATU'],
	'BAHASA' => $row['BAHASA'],
	'TINGGAL_DI' => $row['TINGGAL_DI'],
	'JARAK_SEK' => $row['JARAK_SEK'],
	'KELAINAN_JASMANI' => $row['KELAINAN_JASMANI'],
	'BERAT_BADAN' => $row['BERAT_BADAN'],
	'TINGGI_BADAN' => $row['TINGGI_BADAN'],
	'ASAL_SMP' => $row['ASAL_SMP'],
	'NO_STL_SMP' => $row['NO_STL_SMP'],
	'TANGGAL_STL_SMP' => $row['TANGGAL_STL_SMP'],
	'LAMA_BELAJAR_SMP' => $row['LAMA_BELAJAR_SMP'],
	'ASAL_SMA' => $row['ASAL_SMA'],
	'KD_TINGKAT_KELAS' => $row['KD_TINGKAT_KELAS'],
	'KD_PROGRAM_PENGAJARAN' => $row['KD_PROGRAM_PENGAJARAN'],
	'DITERIMA_TANGGAL' => $row['DITERIMA_TANGGAL'],
	'PINDAH_ALASAN' => $row['PINDAH_ALASAN'],
	'HUBUNGI' => $row['HUBUNGI'],
	'TANGGUNG_BIAYA' => $row['TANGGUNG_BIAYA'],
	'TEMP_AKSES_NET' => $row['TEMP_AKSES_NET'],
	'FREK_AKSES_NET' => $row['FREK_AKSES_NET'],
	'FREK_REKRE_KEL' => $row['FREK_REKRE_KEL'],
	'NILAI' => $row['NILAI'],
	'NO_INDUK' => $row['NO_INDUK'],
	'DIR_FOTO' => $row['DIR_FOTO'],
	'STATUS_ENTRI' => $row['STATUS_ENTRI'],
	'KD_JENIS_KETUNAAN' => $row['KD_JENIS_KETUNAAN'],
	'KD_STATUS_DALAM_KELUARGA' => $row['KD_STATUS_DALAM_KELUARGA'],
	'TANGGAL_SKHUN_SMP' => $row['TANGGAL_SKHUN_SMP'],
	'NO_SKHUN_SMP' => $row['NO_SKHUN_SMP'],
	'NISN' => $row['NISN'],
	'NIK' => $row['NIK'],
	'JENIS_TINGGAL' => $row['JENIS_TINGGAL'],
	'KELURAHAN_DESA' => $row['KELURAHAN_DESA'],
	'KECAMATAN' => $row['KECAMATAN'],
	'KABUPATEN_KOTA' => $row['KABUPATEN_KOTA'],
	'PROPINSI' => $row['PROPINSI'],
	'KD_AREA' => $row['KD_AREA'],
	'KD_JARAK_SEK' => $row['KD_JARAK_SEK'],
	'ALAT_TRANSPORTASI' => $row['ALAT_TRANSPORTASI'],
	'EMAIL_PRIBADI' => $row['EMAIL_PRIBADI'],
	'USERNAME' => $row['USERNAME'],
	'TANGGAL_AKSES' => $row['TANGGAL_AKSES'],
 );
		}
        $this->db->flush_cache(); 
		return $temp_result;
	}





    /**
     *  Some utility methods
     */
    function fields( $withID = FALSE )
    {
        $fs = array(
	'NIS' => lang('NIS'),
	'NO_CALSIS' => lang('NO_CALSIS'),
	'NM_SISWA' => lang('NM_SISWA'),
	'NM_PANGGILAN' => lang('NM_PANGGILAN'),
	'KD_JENIS_KELAMIN' => lang('KD_JENIS_KELAMIN'),
	'KOTA_LAHIR' => lang('KOTA_LAHIR'),
	'TANGGAL_LAHIR' => lang('TANGGAL_LAHIR'),
	'ALAMAT' => lang('ALAMAT'),
	'RT' => lang('RT'),
	'RW' => lang('RW'),
	'KD_POS' => lang('KD_POS'),
	'KD_GOL_DARAH' => lang('KD_GOL_DARAH'),
	'KD_AGAMA' => lang('KD_AGAMA'),
	'NO_TELP' => lang('NO_TELP'),
	'NO_HP' => lang('NO_HP'),
	'STATUS_SISWA' => lang('STATUS_SISWA'),
	'KEWARGANEGARAAN' => lang('KEWARGANEGARAAN'),
	'ANAK_KE' => lang('ANAK_KE'),
	'JUMLAH_KANDUNG' => lang('JUMLAH_KANDUNG'),
	'JUMLAH_TIRI' => lang('JUMLAH_TIRI'),
	'JUMLAH_ANGKAT' => lang('JUMLAH_ANGKAT'),
	'STATUS_YATIM_PIATU' => lang('STATUS_YATIM_PIATU'),
	'BAHASA' => lang('BAHASA'),
	'TINGGAL_DI' => lang('TINGGAL_DI'),
	'JARAK_SEK' => lang('JARAK_SEK'),
	'KELAINAN_JASMANI' => lang('KELAINAN_JASMANI'),
	'BERAT_BADAN' => lang('BERAT_BADAN'),
	'TINGGI_BADAN' => lang('TINGGI_BADAN'),
	'ASAL_SMP' => lang('ASAL_SMP'),
	'NO_STL_SMP' => lang('NO_STL_SMP'),
	'TANGGAL_STL_SMP' => lang('TANGGAL_STL_SMP'),
	'LAMA_BELAJAR_SMP' => lang('LAMA_BELAJAR_SMP'),
	'ASAL_SMA' => lang('ASAL_SMA'),
	'KD_TINGKAT_KELAS' => lang('KD_TINGKAT_KELAS'),
	'KD_PROGRAM_PENGAJARAN' => lang('KD_PROGRAM_PENGAJARAN'),
	'DITERIMA_TANGGAL' => lang('DITERIMA_TANGGAL'),
	'PINDAH_ALASAN' => lang('PINDAH_ALASAN'),
	'HUBUNGI' => lang('HUBUNGI'),
	'TANGGUNG_BIAYA' => lang('TANGGUNG_BIAYA'),
	'TEMP_AKSES_NET' => lang('TEMP_AKSES_NET'),
	'FREK_AKSES_NET' => lang('FREK_AKSES_NET'),
	'FREK_REKRE_KEL' => lang('FREK_REKRE_KEL'),
	'NILAI' => lang('NILAI'),
	'NO_INDUK' => lang('NO_INDUK'),
	'DIR_FOTO' => lang('DIR_FOTO'),
	'STATUS_ENTRI' => lang('STATUS_ENTRI'),
	'KD_JENIS_KETUNAAN' => lang('KD_JENIS_KETUNAAN'),
	'KD_STATUS_DALAM_KELUARGA' => lang('KD_STATUS_DALAM_KELUARGA'),
	'TANGGAL_SKHUN_SMP' => lang('TANGGAL_SKHUN_SMP'),
	'NO_SKHUN_SMP' => lang('NO_SKHUN_SMP'),
	'NISN' => lang('NISN'),
	'NIK' => lang('NIK'),
	'JENIS_TINGGAL' => lang('JENIS_TINGGAL'),
	'KELURAHAN_DESA' => lang('KELURAHAN_DESA'),
	'KECAMATAN' => lang('KECAMATAN'),
	'KABUPATEN_KOTA' => lang('KABUPATEN_KOTA'),
	'PROPINSI' => lang('PROPINSI'),
	'KD_AREA' => lang('KD_AREA'),
	'KD_JARAK_SEK' => lang('KD_JARAK_SEK'),
	'ALAT_TRANSPORTASI' => lang('ALAT_TRANSPORTASI'),
	'EMAIL_PRIBADI' => lang('EMAIL_PRIBADI'),
	'USERNAME' => lang('USERNAME'),
	'TANGGAL_AKSES' => lang('TANGGAL_AKSES')
);

        if( $withID == FALSE )
        {
            unset( $fs[0] );
        }
        return $fs;
    }  
    


    function pagination( $bool )
    {
        $this->pagination_enabled = ( $bool === TRUE ) ? TRUE : FALSE;
    }



    /**
     *  Parses the table data and look for enum values, to match them with language variables
     */             
    function metadata()
    {
        $this->load->library('explain_table');

        $metadata = $this->explain_table->parse( 't_siswa' );

        foreach( $metadata as $k => $md )
        {
            if( !empty( $md['enum_values'] ) )
            {
                $metadata[ $k ]['enum_names'] = array_map( 'lang', $md['enum_values'] );                
            } 
        }
        return $metadata; 
    }
}
